package com.iris.live.services.services.impl;

import com.iris.live.services.data.models.RoleItemInfoModel;
import com.iris.live.services.data.models.RoleModel;
import com.iris.live.services.data.repositories.RoleItemSqlRepository;
import com.iris.live.services.data.repositories.RoleRepository;
import com.iris.live.services.services.RoleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by yitianle on 2017/8/10.
 */
@Service
public class RoleServiceImpl implements RoleService{

    private Logger logger = LoggerFactory.getLogger(RoleService.class);

    @Autowired
    private RoleRepository roleRepository;
    @Autowired
    private RoleItemSqlRepository roleItemSqlRepository;

    @Override
    public List<RoleModel> getAllRoleByGroup(Integer group,int areaParentId) {
        if (group ==0){
            return roleRepository.findRoleListByDealer();
        }
       switch (areaParentId){
           case 0:
               return roleRepository.findRoleListByGroups();
           case 1:
               return roleRepository.findRoleListByGroup();
           default:
               return roleRepository.findRoleListByGroupNoAdmin();
       }
    }

    @Override
    public RoleModel getRoleExists(Integer groupType, String role) {
        return roleRepository.getRoleExists(groupType,role);
    }

    @Override
    public RoleModel getRoleInfo(String role) {
        return roleRepository.getRoleInfo(role);
    }
}
